package software.lib.util;

import org.neo4j.driver.v1.Record;
import org.neo4j.driver.v1.StatementResult;
import software.lib.util.NeoDriver;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class TrainData {
	public static final String file_path = "D:\\WorkSpaces\\python\\lshCorba\\";

	public static void main(String[] args){
		try (NeoDriver neodriver = new NeoDriver() ){
			File txt = new File(file_path+"title.txt");
			FileWriter fw;
			fw = new FileWriter(txt);
			BufferedWriter writer = new BufferedWriter(fw);
			StatementResult result = neodriver.query( "MATCH (n:gig) return ID(n) As id, n.id As gid, n.name As title");
			while ( result.hasNext() ){
				Record record = result.next();
				String id = record.get("id").toString();
				String gid = record.get("gid").asString();
				String title = record.get("title").asString().trim();
				writer.write(id+" "+gid+" "+title+"\n");
			}
			writer.close();
			fw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
